package com.feiyu.base;

/**
 * @author nanshouxiao@teacher.com.cn
 * @date 2017-10-31 10:22
 */
public class DigitClass {
    public static void main(String[] args) {
        int int1 = 0b1000_0000;
        System.out.println(Integer.toHexString(0b1101100000000000));
        int S = 0X3FF;
        System.out.println(Integer.toString(S, 2));
        printBinary(0x3ff);
    }

    private static void printBinary(int num) {
        String str = Integer.toBinaryString(num);
        int len = str.length();
        int lef = len % 4;
        StringBuilder sbr = new StringBuilder();
        char[] chars = str.toCharArray();
        ;
        for (int i = 0; i < len; i++) {
            if (i >= lef && (i - lef) % 4 == 0) {
                sbr.append("_");
            }
            sbr.append(chars[i]);
        }
        System.out.println(sbr);
    }
}
